<?php
include_once("common.inc.php");

// we assume the request comes from Second Life or OpenSimulator and don't do a lot of checks

if ($db->query("REPLACE INTO objects (Key, Name, PermURL, Location, OwnerKey, OwnerName, LastUpdate) VALUES ('" .
	$_SERVER['HTTP_X_SECONDLIFE_OBJECT_KEY'] . "','" .
	addslashes($_SERVER['HTTP_X_SECONDLIFE_OBJECT_NAME']) . "','" .
	$_REQUEST['PermURL'] . "','" .
	$_SERVER['HTTP_X_SECONDLIFE_REGION'] . "','" .
	$_SERVER['HTTP_X_SECONDLIFE_OWNER_KEY'] . "','" .
	$_SERVER['HTTP_X_SECONDLIFE_OWNER_NAME'] . "','" .
	$_REQUEST['timestamp'] . "')", SQLITE_BOTH, $error_msg) === FALSE)
{
	header("HTTP/1.0 503 Service Unavailable");
	printf("REPLACE query failed: %s\n", $error_msg);
	exit();
}
header("HTTP/1.0 200 OK");
header("Content-type: text/plain; charset=utf-8");
echo "'" . $_SERVER['HTTP_X_SECONDLIFE_OBJECT_NAME'] . "' successfully updated!";

	
?>